package com.ym.controller.medical;

import com.github.pagehelper.PageInfo;
import com.ym.common.utils.page.PageDomain;
import com.ym.core.annotation.Log;
import com.ym.core.domain.APIResponse;
import com.ym.core.domain.BaseController;
import com.ym.soso.domain.entity.OrgCommentRecordEntity;
import com.ym.soso.domain.param.AuditParam;
import com.ym.soso.domain.param.OrgCommentRecordQueryParam;
import com.ym.soso.domain.vo.OrgCommentRecordListPcVO;
import com.ym.soso.service.IOrgCommentRecordSV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 评价记录Controller
 * 
 * @author ym
 * @date 2020-08-20
 */
@Api(tags = "soso-评价记录")
@RestController
@Validated
@RequestMapping("/sys/orgCommentRecord")
public class OrgCommentRecordController extends BaseController {

    @Autowired
    private IOrgCommentRecordSV orgCommentRecordSV;

    @ApiOperation("查询评价记录列表")
    @Log
    @GetMapping("/list")
    public APIResponse<PageInfo<OrgCommentRecordListPcVO>> list(@Valid OrgCommentRecordQueryParam queryParam) {
        PageDomain.startPage();
        List<OrgCommentRecordListPcVO> list = orgCommentRecordSV.selectListPC(queryParam);
        return successPage(list);
    }

    @ApiOperation("获取评价记录详细信息")
    @Log
    @GetMapping(value = "/info")
    public APIResponse<OrgCommentRecordEntity> info(@RequestParam Long id) {
        OrgCommentRecordEntity data = orgCommentRecordSV.selectById(id);
        return successData(data);
    }


    @ApiOperation("删除评价记录")
    @Log
    @PostMapping("/delete")
    public APIResponse delete(@RequestBody @Valid @NotNull Long[] ids) {
        int result = orgCommentRecordSV.deleteByIds(ids);
        return successData(result);
    }

    @ApiOperation("审核评价记录")
    @Log
    @PostMapping("/audit")
    public APIResponse audit(@RequestBody @Valid AuditParam auditParam) {
        orgCommentRecordSV.audit(auditParam);
        return success();
    }
}
